package reading.web;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import reading.common.WebUtils;
import reading.common.domain.AuthToken;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 默认HTTP拦截器
 *
 * @author yangbajing(yangbajing @ gmail.com) on 2016-09-23.
 * @author yangbajing(yangbajing @ gmail.com)
 */
public class DefaultHttpInterceptor extends HandlerInterceptorAdapter {
    /**
     * 登出uri
     */
    private final static String LOGIN_OUT = "/sign/signout";
    private final static String ADMIN_RUI = "/admin";
    private WebUtils webUtils;

    public DefaultHttpInterceptor( WebUtils webUtils) {
        this.webUtils = webUtils;
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        response.addHeader("Expires", "-1");
        response.addHeader("Cache-Control", "no-cache");
        return true;
    }


    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        AuthToken.removeOnThreadLocal();
    }
}
